/*
 * Copyright 2012 Gayan Perera
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package gap.maven.script.components;

import gap.maven.script.components.api.ArtifactFile;
import gap.maven.script.components.api.ArtifactFileFactory;
import gap.maven.script.components.api.POMArtifactFile;

import org.apache.maven.project.MavenProject;

public class ArtifactFileFactoryImpl implements ArtifactFileFactory {
    private final ComponentContext context;

    public ArtifactFileFactoryImpl(ComponentContext context) {
        this.context = context;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * gap.maven.scriptrunner.components.ArtifactFileFactory#createArtifactFile
     * (java.lang.String, java.lang.String, java.lang.String, java.lang.String,
     * java.lang.String, gap.maven.scriptrunner.components.ComponentContext)
     */
    public ArtifactFile createArtifactFile(String groupId, String artifactId, String version, String type,
            String classifier) {
        return new MavenArtifactFile(groupId, artifactId, version, type, classifier, context);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * gap.maven.scriptrunner.components.ArtifactFileFactory#createArtifactFile
     * (java.lang.String, java.lang.String, java.lang.String, java.lang.String,
     * gap.maven.scriptrunner.components.ComponentContext)
     */
    public ArtifactFile createArtifactFile(String groupId, String artifactId, String version, String type) {
        return new MavenArtifactFile(groupId, artifactId, version, type, "", context);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * gap.maven.scriptrunner.components.ArtifactFileFactory#createMainArtifactFile
     * (java.lang.String, java.lang.String, java.lang.String,
     * gap.maven.scriptrunner.components.ComponentContext)
     */
    public ArtifactFile createMainArtifactFile(String groupId, String artifactId, String version) {
        return new MavenArtifactFile(groupId, artifactId, version, "jar", "", context);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * gap.maven.scriptrunner.components.ArtifactFileFactory#createPOMFile(java
     * .lang.String, java.lang.String, java.lang.String,
     * gap.maven.scriptrunner.components.ComponentContext)
     */
    public POMArtifactFile createPOMFile(String groupId, String artifactId, String version) {
        return new MavenArtifactFile(groupId, artifactId, version, "pom", "", context);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * gap.maven.scriptrunner.components.ArtifactFileFactory#createPOMFile(org
     * .apache.maven.project.MavenProject,
     * gap.maven.scriptrunner.components.ComponentContext)
     */
    public POMArtifactFile createPOMFile(MavenProject project) {
        return new MavenArtifactFile(project, context);
    }
}
